const dotenv = require('dotenv');
const result = dotenv.config();
if (result.error) {
    throw result.error;
}
const config = require('./config');
const MetamonApi = require('./metamon_api');


async function sum() {
    let metamonApi = new MetamonApi(config.address, config.chain, config.privateKey);
    let accessToken =  await metamonApi.login();
    metamonApi.setAccessToken(accessToken);
    let metamons = await metamonApi.getMetamonList();
    let b320T324 = 0 ;
    let b315T319 = 0;
    let l314 = 0;
    let g325 = 0;
    for(let i=0; i<metamons.length; i++) {
        let item = metamons[i];
        console.log("宠物#"+item.tokenId+"，等级："+item.level+"，稀有度："+item.rarity+"，能力值："+item.sca);
        let sca = item.sca;
        if (sca <= 314) {
            l314 ++;
        } else if (315 <= sca && sca <= 319) {
            b315T319 ++;
        } else if (320 <= sca && sca <= 324) {
            b320T324 ++;
        } else {
            g325 ++;
        }

    }
    console.log("===================================================================");
    console.log("元兽数量："+metamons.length);
    console.log("能力统计：325以上："+g325+"，320-324："+b320T324+"，315-319："+b315T319+"，314以下："+l314);

}

sum();